package com.wzu.zlb.ems.service.impl;

import com.wzu.zlb.ems.dao.DesignMapper;
import com.wzu.zlb.ems.dao.ProductMapper;
import com.wzu.zlb.ems.pojo.Design;
import com.wzu.zlb.ems.pojo.Product;
import com.wzu.zlb.ems.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Transactional
@Service("productService")
public class ProductServiceImpl implements ProductService {
    @Autowired
    ProductMapper productMapper;
    @Autowired
    DesignMapper designMapper;


    @Override
    public List<Product> findAllProduct() {
        return productMapper.findAllProducts();
    }

    @Override
    public List<Product> searchProduct(Product product) {
        return productMapper.searchProducts(product);
    }

    @Override
    public Product findProductById(Integer productId) {
        return productMapper.findProductById(productId);
    }

    @Override
    public Integer addProduct(Product product) {
        return productMapper.AddProduct(product);
    }

    @Override
    public Integer modifyProduct(Product product) {
        return productMapper.ModifyProduct(product);
    }

    @Override
    public Integer deleteProduct(Integer id) {
        return productMapper.DeleteProduct(id);
    }

    public List<Design> findDesignsByProductId(Integer id){
        return designMapper.findDesignsByProductId(id);
    }

    @Override
    public Integer addDesign(Design design) {
        return designMapper.addDesign(design);
    }

    @Override
    public Integer modifyDesign(Design design) {
        return designMapper.modifyDesign(design);
    }

    @Override

    public Integer deleteDesign(Design design) {
        return designMapper.deleteDesign(design);
    }

    @Override
    public Product searchProduct(String productName) {
        return productMapper.searchProduct(productName);
    }
}
